package com.scoressystem.controller;


import com.scoressystem.utils.Results;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/user")
public class CommonController {

    @GetMapping("/getnowuser")
    public Results getnowUser(HttpSession session) {
        Object nowusername= session.getAttribute("nowusername");
        if (nowusername != null) {
            return new Results<>("0","登录成功",nowusername);
        }else {
            return new Results<>("1","登陆失败",nowusername);
        }
    }

    @RequestMapping("/loginOut")
    public Results loginOut(HttpSession session) {
        session.removeAttribute("nowusername");
        session.invalidate();
        return new Results<>("0","退出成功");
    }
}
